From 1097a86bd4527db5ebe227798e66adf64daf5bf3 Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Tue, 30 Apr 2024 17:30:55 -0700
Subject: feat(badges): sort by time after grouping

---
 src/routes/user/[user]/badges/+page.svelte | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'src/routes/user/[user]/badges/+page.svelte')

diff --git a/src/routes/user/[user]/badges/+page.svelte b/src/routes/user/[user]/badges/+page.svelte
index 2b7dd65f..f9bdefa7 100644
--- a/src/routes/user/[user]/badges/+page.svelte
+++ b/src/routes/user/[user]/badges/+page.svelte
@@ -817,7 +817,11 @@
 								</div>
 							{/if}
 
-							{#each groupedBadges as [category, badges]}
+							{#each groupedBadges as [category, unsortedBadges]}
+								{@const badges = unsortedBadges.sort(
+									(a, b) => new Date(b.time || 0).getTime() - new Date(a.time || 0).getTime()
+								)}
+
 								<details open={categoryFilter ? categoryFilter === category : true}>
 									<summary>{category}</summary>
 
-- 
cgit v1.2.3

